const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const config = {
  entry: './src/index.jsx',
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [{
        test: /\.js|jsx?$/,
        include: [
          path.join(__dirname, 'src'),
          path.join(__dirname, 'src/components/')
        ],
        loader: 'babel-loader'
      },
      {
        test: /\.scss?$/,
        include: [
          path.join(__dirname, 'src'),
          path.join(__dirname, 'src/components/')
        ],
        use: ['style-loader', 'css-loader', 'sass-loader']
      }
    ]
  },
  resolve: {
    extensions: [".js", ".json", ".jsx", ".css"]
  },
  devServer: {
    contentBase: path.join(__dirname, "dist"),
    compress: true,
    port: 9000,
    hot: true
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new HtmlWebpackPlugin({
      title: 'webpack-react-frame',
      template: 'src/index.html'
    })
  ]
}

module.exports = config;